package com.atguigu.blog.service.impl;

import com.atguigu.blog.mapper.ArticleMapper;
import com.atguigu.blog.pojo.Article;
import com.atguigu.blog.pojo.Category;
import com.atguigu.blog.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author MikeCoder
 * @create 2023-11-2421:05
 * @description:
 * @verson:
 */
@Service
@Transactional
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleMapper articleMapper;
    @Override
    @Transactional(readOnly = true)
    public List<Article> showArticleByCid(Category category) {
        return articleMapper.selectArticleByCid(category);
    }

    @Override
    @Transactional(readOnly = true)
    public Article showArticleById(Long id) {
        return articleMapper.selectArticelById(id);
    }

    @Override
    @Transactional(readOnly = true)
    public List<Article> showArticleByUid(Long uid) {
        return articleMapper.selectArticleByUid(uid);
    }

    @Override
    public Integer change(Article article) {
        return articleMapper.update(article);
    }

    @Override
    public Integer add(Article article) {
        return articleMapper.insert(article);
    }

    @Override
    public Integer remove(Long id) {
        return articleMapper.delete(id);
    }
}
